翻訳と辞書
Words near each other
・ Allocasuarina paludosa
・ Allocasuarina portuensis
・ Allocasuarina simulans
・ Allocasuarina torulosa
・ Allocasuarina verticillata
・ Allocate-on-flush
・ Allocation
・ Allocation (oil and gas)
・ Allocation de Solidarité aux Personnes Agées
・ Allocation group
・ Allocation money
・ Allocation of Rhodes Scholarships
・ Allocation questionnaire
・ Allocation site
・ Allocative efficiency
Allocator (C++)
・ Allocatur
・ Allocentrism
・ Allocer
・ Allocera
・ Allocera bicarinatum
・ Allocera dilaticorne
・ Allocera spencei
・ Allocerastichus
・ Alloceratites
・ Allocetraria
・ Allocharopa
・ Allocharopa erskinensis
・ Allocharopa okeana
・ Allocharopa tarravillensis


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Allocator (C++) : ウィキペディア英語版
Allocator (C++)

In C++ computer programming, allocators are an important component of the C++ Standard Library. The standard library provides several data structures, such as list and set, commonly referred to as containers. A common trait among these containers is their ability to change size during the execution of the program. To achieve this, some form of dynamic memory allocation is usually required. Allocators handle all the requests for allocation and deallocation of memory for a given container. The C++ Standard Library provides general-purpose allocators that are used by default, however, custom allocators may also be supplied by the programmer.
Allocators were invented by Alexander Stepanov as part of the Standard Template Library (STL). They were originally intended as a means to make the library more flexible and independent of the underlying memory model, allowing programmers to utilize custom pointer and reference types with the library. However, in the process of adopting STL into the C++ standard, the C++ standardization committee realized that a complete abstraction of the memory model would incur unacceptable performance penalties. To remedy this, the requirements of allocators were made more restrictive. As a result, the level of customization provided by allocators is more limited than was originally envisioned by Stepanov.
Nevertheless, there are many scenarios where customized allocators are desirable. Some of the most common reasons for writing custom allocators include improving performance of allocations by using memory pools, and encapsulating access to different types of memory, like shared memory or garbage-collected memory. In particular, programs with many frequent allocations of small amounts of memory may benefit greatly from specialized allocators, both in terms of running time and memory footprint.
==Background==

Alexander Stepanov and Meng Lee presented the Standard Template Library to the C++ standards committee in March 1994.〔 The library received preliminary approval, although a few issues were raised. In particular, Stepanov was requested to make the library containers independent of the underlying memory model,〔 which led to the creation of allocators. Consequently, all of the STL container interfaces had to be rewritten to accept allocators.
In adapting STL to be included in the C++ Standard Library, Stepanov worked closely with several members of the standards committee, including Andrew Koenig and Bjarne Stroustrup, who observed that custom allocators could potentially be used to implement persistent storage STL containers, which Stepanov at the time considered an "important and interesting insight".〔
The original allocator proposal incorporated some language features that had not yet been accepted by the committee, namely the ability to use template arguments that are themselves templates. Since these features could not be compiled by any existing compiler, there was, according to Stepanov, "an enormous demand on Bjarne ()'s and Andy ()'s time trying to verify that we were using these non-implemented features correctly."〔 Where the library had previously used pointer and reference types directly, it would now only refer to the types defined by the allocator. Stepanov later described allocators as follows: "A nice feature of STL is that the only place that mentions the machine-related types (...) is encapsulated within roughly 16 lines of code."〔
While Stepanov had originally intended allocators to completely encapsulate the memory model, the standards committee realized that this approach would lead to unacceptable efficiency degradations.〔〔 To remedy this, additional wording was added to the allocator requirements. In particular, container implementations may assume that the allocator's type definitions for pointers and related integral types are equivalent to those provided by the default allocator, and that all instances of a given allocator type always compare equal,〔〔 effectively contradicting the original design goals for allocators and limiting the usefulness of allocators that carry state.〔
Stepanov later commented that, while allocators "are not such a bad () in theory (...) ()nfortunately they cannot work in practice". He observed that to make allocators really useful, a change to the core language with regards to references was necessary.〔
The 2011 revision of the C++ Standard removed the weasel words requiring that allocators of a given type always compare equal and use normal pointers. These changes make stateful allocators much more useful and allow allocators to manage out-of-process shared memory.〔〔 The current purpose of allocators is to give the programmer control over memory allocation within containers, rather than to adapt the address model of the underlying hardware. In fact, the revised standard eliminated the ability of allocators to represent extensions to the C++ address model, formally (and deliberately) eliminating their original purpose.〔

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Allocator (C++)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.